package com.ybc.chinese.fragment;

import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.ybc.chinese.R;
import com.ybc.chinese.activity.InduceActivity;
import com.ybc.chinese.activity.JokeActivity;
import com.ybc.chinese.activity.OutsideReadActivity;
import com.ybc.chinese.activity.TeacherVideoActivity;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * <p>发现<p/>
 * Created by Yubch on 17/2/18.
 */
public class DiscoveryFragment extends BaseFragment {
    @Bind(R.id.tv_title)
    TextView tvTitle;
    private Context mCtx;

    private static final String SHOP_URL = "https://ai.taobao.com/search/index.htm?key=%E9%AB%98%E8%80%83&pid=mm_30883043_22092860_73730425";

    public static DiscoveryFragment newInstance() {
        DiscoveryFragment homeFragment = new DiscoveryFragment();
        return homeFragment;
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        mCtx = getActivity();
        View view = inflater.from(mCtx).inflate(R.layout.fragment_discovery, container, false);
        ButterKnife.bind(this, view);
        initView();
        return view;
    }

    private void initView() {
        tvTitle.setText(getString(R.string.discovery));
    }

    @Override
    public void onDestroyView() {
        super.onDestroyView();
        ButterKnife.unbind(this);
    }

    @OnClick(R.id.layout_video)
    public void video() {
        Intent intent = new Intent(mCtx, TeacherVideoActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.layout_read)
    public void read() {
        Intent intent = new Intent(mCtx, OutsideReadActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.layout_induce)
    public void induce() {
        Intent intent = new Intent(mCtx, InduceActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.layout_joke)
    public void joke() {
        Intent intent = new Intent(mCtx, JokeActivity.class);
        startActivity(intent);
    }

    @OnClick(R.id.layout_shop)
    public void shop() {
        Intent intent = new Intent();
        intent.setAction("android.intent.action.VIEW");
        Uri contentUrl = Uri.parse(SHOP_URL);
        intent.setData(contentUrl);
        startActivity(intent);
    }
}
